<?php 
/**
 * 登陆控制器 
 */
class LoginController extends Controller{
    /**
     * 登陆
     */
    public function login(){
         //p($_POST);die
       if(IS_POST){
       		
       		$username = $_POST['account'];  
       		//post(用户)提交过来的密码和数据库的密码比对
       		$userData = M()->query("SELECT * FROM hd_user WHERE username='{$username}'"); 
			if(!$userData) $this->error('用户不存在','index.php');
			
			$userData = $userData[0];
			if($userData['lock']==1){$this->error('用户已锁定','index.php');}
            if( $userData['passwd']==md5($_POST['pwd'])){
                $_SESSION['uid'] = $userData['uid'];
                $_SESSION['uname'] = $userData['username'];
                $_SESSION['upoint'] = $userData['point'];
                $_SESSION['uexp'] = $userData['exp'];
				$this->success('登陆成功','index.php');
            }
			
       }
    }
	
	/**
	 * 退出
	 */
	public function out(){
    // 删除变量
    session_unset();
    // 删除文件
    session_destroy();
    $this->success('退出成功','index.php');
	}
	
	
	
 }
 
 
 
 
 
 
 
 
 
 
 


 ?>